﻿using System;
using System.Web.Services;
using Business;
using Business.DbConnect.Constant;

namespace ServerMotorManagement.Services
{
    /// <summary>
    /// Summary description for TicketManager
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    // [System.Web.Script.Services.ScriptService]
    public class TicketManager : System.Web.Services.WebService
    {
        [WebMethod]
        public string CheckTicket(String username, String password, String motorbikePlate)
        {
            // Check username + password
            // If not authenticate, return String.Empty

            #region Check Authentication

            if (!UserService.CheckClientAuthentication(username, password))
                return null;

            #endregion Check Authentication

            // Done check
            var tmp = TicketBusiness.SelectTypeByPlate(motorbikePlate);
            var tmp1 = MotorTypeBusiness.SelectMotorTypeByPlate(motorbikePlate);
            if (tmp == null)
                return "Vé ngày";
            else
                return tmp.Description;
        }

        [WebMethod]
        public string CheckMotorType(String username, String password, String motorbikePlate)
        {
            // Check username + password
            // If not authenticate, return String.Empty

            #region Check Authentication

            if (!UserService.CheckClientAuthentication(username, password))
                return null;

            #endregion Check Authentication

            // Done check
            //var tmp = TicketBusiness.SelectTypeByPlate(motorbikePlate);
            var tmp1 = MotorTypeBusiness.SelectMotorTypeByPlate(motorbikePlate);
            if (tmp1 == null)
                return null;
            else
                return tmp1.Description;
        }
    }
}